//Condition Expression
grammar ConditionExpr;

tokens{
	AND	='and';
	OR	='or';
	AND_1	='*';
	OR_1 	='+';
	AND_2	='&&';
	OR_2	='||';
}

expr returns [boolean value]
	:
		e = atom {$value = $e.value;}
		(
			AND e=atom{$value=($value && $e.value);}
			|
			OR e=atom{$value=($value || $e.value);}
			|
			AND_1 e=atom{$value=($value && $e.value);}
			|
			OR_1 e=atom{$value=($value || $e.value);}
			|
			AND_2 e=atom{$value=($value && $e.value);}
			|
			OR_2 e=atom{$value=($value || $e.value);}
		)*
	;
	
atom returns [boolean value]
	:	BV {$value = Boolean.parseBoolean($BV.text);}
	|	COND {$value = true;}
	|	'(' expr ')' {$value = $expr.value;}		
	;

COND	:	'1'..'9''0'..'9'*;
BV	:	'true'|'false';

